package com.weibo.net;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.text.TextUtils;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import java.util.zip.GZIPInputStream;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;

public class Utility
{
  public static final String BOUNDARY = "7cd4a6d158c";
  public static final String END_MP_BOUNDARY = "--7cd4a6d158c--";
  public static final String HTTPMETHOD_DELETE = "DELETE";
  public static final String HTTPMETHOD_GET = "GET";
  public static final String HTTPMETHOD_POST = "POST";
  public static final String MP_BOUNDARY = "--7cd4a6d158c";
  public static final String MULTIPART_FORM_DATA = "multipart/form-data";
  private static final int SET_CONNECTION_TIMEOUT = 50000;
  private static final int SET_SOCKET_TIMEOUT = 200000;
  private static HttpHeaderFactory mAuth;
  private static WeiboParameters mRequestHeader = new WeiboParameters();
  private static Token mToken = null;

  public static char[] base64Encode(byte[] paramArrayOfByte)
  {
    int i4;
    int i5;
    int i6;
    int i7;
    char[] arrayOfChar1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".toCharArray();
    char[] arrayOfChar2 = new char[4 * (2 + paramArrayOfByte.length) / 3];
    int i = 0;
    int j = 0;
    if (i >= paramArrayOfByte.length)
      return arrayOfChar2;
    int k = 0;
    int l = 0;
    int i1 = (0xFF & paramArrayOfByte[i]) << 8;
    if (i + 1 < paramArrayOfByte.length)
    {
      i1 |= 0xFF & paramArrayOfByte[(i + 1)];
      l = 1;
    }
    int i2 = i1 << 8;
    if (i + 2 < paramArrayOfByte.length)
    {
      i2 |= 0xFF & paramArrayOfByte[(i + 2)];
      k = 1;
    }
    int i3 = j + 3;
    if (k != 0)
    {
      i4 = i2 & 0x3F;
      arrayOfChar2[i3] = arrayOfChar1[i4];
      i5 = i2 >> 6;
      i6 = j + 2;
      if (l == 0)
        break label220;
      i7 = i5 & 0x3F;
    }
    while (true)
    {
      while (true)
      {
        while (true)
        {
          arrayOfChar2[i6] = arrayOfChar1[i7];
          int i8 = i5 >> 6;
          arrayOfChar2[(j + 1)] = arrayOfChar1[(i8 & 0x3F)];
          int i9 = i8 >> 6;
          arrayOfChar2[(j + 0)] = arrayOfChar1[(i9 & 0x3F)];
          i += 3;
          j += 4;
        }
        i4 = 64;
      }
      label220: i7 = 64;
    }
  }

  public static void clearCookies(Context paramContext)
  {
    CookieSyncManager.createInstance(paramContext);
    CookieManager.getInstance().removeAllCookie();
  }

  public static void clearRequestHeader()
  {
    mRequestHeader.clear();
  }

  public static Bundle decodeUrl(String paramString)
  {
    String[] arrayOfString1;
    int i;
    int j;
    Bundle localBundle = new Bundle();
    if (paramString != null)
    {
      arrayOfString1 = paramString.split("&");
      i = arrayOfString1.length;
      j = 0;
    }
    while (true)
    {
      if (j >= i)
        return localBundle;
      String[] arrayOfString2 = arrayOfString1[j].split("=");
      localBundle.putString(URLDecoder.decode(arrayOfString2[0]), URLDecoder.decode(arrayOfString2[1]));
      ++j;
    }
  }

  public static String encodeParameters(WeiboParameters paramWeiboParameters)
  {
    String str1;
    StringBuilder localStringBuilder;
    int i;
    int j;
    if ((paramWeiboParameters == null) || (isBundleEmpty(paramWeiboParameters)))
      str1 = "";
    while (true)
    {
      return str1;
      localStringBuilder = new StringBuilder();
      i = 0;
      j = 0;
      if (j < paramWeiboParameters.size())
        break;
      str1 = localStringBuilder.toString();
    }
    String str2 = paramWeiboParameters.getKey(j);
    if (i != 0)
      localStringBuilder.append("&");
    try
    {
      localStringBuilder.append(URLEncoder.encode(str2, "UTF-8")).append("=").append(URLEncoder.encode(paramWeiboParameters.getValue(str2), "UTF-8"));
      label96: ++i;
      ++j;
    }
    catch (UnsupportedEncodingException localUnsupportedEncodingException)
    {
      break label96:
    }
  }

  public static String encodePostBody(Bundle paramBundle, String paramString)
  {
    String str2;
    if (paramBundle == null)
    {
      str2 = "";
      return str2;
    }
    StringBuilder localStringBuilder = new StringBuilder();
    Iterator localIterator = paramBundle.keySet().iterator();
    while (true)
    {
      String str1;
      do
      {
        while (!(localIterator.hasNext()))
          str2 = localStringBuilder.toString();
        str1 = (String)localIterator.next();
      }
      while (paramBundle.getByteArray(str1) != null);
      localStringBuilder.append("Content-Disposition: form-data; name=\"" + str1 + "\"\r\n\r\n" + paramBundle.getString(str1));
      localStringBuilder.append("\r\n--" + paramString + "\r\n");
    }
  }

  public static String encodeUrl(WeiboParameters paramWeiboParameters)
  {
    StringBuilder localStringBuilder;
    int i;
    int j;
    String str;
    if (paramWeiboParameters == null)
      str = "";
    while (true)
    {
      return str;
      localStringBuilder = new StringBuilder();
      i = 1;
      j = 0;
      if (j < paramWeiboParameters.size())
        break;
      str = localStringBuilder.toString();
    }
    if (i != 0)
      i = 0;
    while (true)
    {
      while (true)
      {
        localStringBuilder.append(URLEncoder.encode(paramWeiboParameters.getKey(j)) + "=" + URLEncoder.encode(paramWeiboParameters.getValue(j)));
        ++j;
      }
      localStringBuilder.append("&");
    }
  }

  public static HttpClient getHttpClient(Context paramContext)
  {
    BasicHttpParams localBasicHttpParams = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(localBasicHttpParams, 50000);
    HttpConnectionParams.setSoTimeout(localBasicHttpParams, 200000);
    DefaultHttpClient localDefaultHttpClient = new DefaultHttpClient(localBasicHttpParams);
    if (!(((WifiManager)paramContext.getSystemService("wifi")).isWifiEnabled()))
    {
      Uri localUri = Uri.parse("content://telephony/carriers/preferapn");
      Cursor localCursor = paramContext.getContentResolver().query(localUri, null, null, null, null);
      if ((localCursor != null) && (localCursor.moveToFirst()))
      {
        String str = localCursor.getString(localCursor.getColumnIndex("proxy"));
        if ((str != null) && (str.trim().length() > 0))
        {
          HttpHost localHttpHost = new HttpHost(str, 80);
          localDefaultHttpClient.getParams().setParameter("http.route.default-proxy", localHttpHost);
        }
      }
    }
    return localDefaultHttpClient;
  }

  public static UrlEncodedFormEntity getPostParamters(Bundle paramBundle)
    throws WeiboException
  {
    UrlEncodedFormEntity localUrlEncodedFormEntity;
    if ((paramBundle == null) || (paramBundle.isEmpty()))
    {
      localUrlEncodedFormEntity = null;
      return localUrlEncodedFormEntity;
    }
    try
    {
      ArrayList localArrayList;
      Iterator localIterator;
      while (true)
      {
        localArrayList = new ArrayList();
        localIterator = paramBundle.keySet().iterator();
        if (localIterator.hasNext())
          break;
        localUrlEncodedFormEntity = new UrlEncodedFormEntity(localArrayList, "UTF-8");
      }
      String str = (String)localIterator.next();
      localArrayList.add(new BasicNameValuePair(str, paramBundle.getString(str)));
    }
    catch (UnsupportedEncodingException localUnsupportedEncodingException)
    {
      throw new WeiboException(localUnsupportedEncodingException);
    }
  }

  // ERROR //
  private static void imageContentToUpload(OutputStream paramOutputStream, android.graphics.Bitmap paramBitmap)
    throws WeiboException
  {
    // Byte code:
    //   0: new 115	java/lang/StringBuilder
    //   3: dup
    //   4: invokespecial 116	java/lang/StringBuilder:<init>	()V
    //   7: astore_2
    //   8: aload_2
    //   9: ldc 23
    //   11: invokevirtual 132	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   14: ldc 183
    //   16: invokevirtual 132	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   19: pop
    //   20: aload_2
    //   21: ldc_w 314
    //   24: invokevirtual 132	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   27: ldc_w 316
    //   30: invokevirtual 132	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   33: ldc_w 318
    //   36: invokevirtual 132	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   39: pop
    //   40: aload_2
    //   41: ldc_w 320
    //   44: invokevirtual 132	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   47: ldc_w 322
    //   50: invokevirtual 132	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   53: ldc_w 324
    //   56: invokevirtual 132	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   59: pop
    //   60: aload_2
    //   61: invokevirtual 124	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   64: invokevirtual 328	java/lang/String:getBytes	()[B
    //   67: astore 6
    //   69: aload_0
    //   70: aload 6
    //   72: invokevirtual 334	java/io/OutputStream:write	([B)V
    //   75: aload_1
    //   76: getstatic 340	android/graphics/Bitmap$CompressFormat:PNG	Landroid/graphics/Bitmap$CompressFormat;
    //   79: bipush 75
    //   81: aload_0
    //   82: invokevirtual 346	android/graphics/Bitmap:compress	(Landroid/graphics/Bitmap$CompressFormat;ILjava/io/OutputStream;)Z
    //   85: pop
    //   86: aload_0
    //   87: ldc 183
    //   89: invokevirtual 328	java/lang/String:getBytes	()[B
    //   92: invokevirtual 334	java/io/OutputStream:write	([B)V
    //   95: aload_0
    //   96: ldc_w 348
    //   99: invokevirtual 328	java/lang/String:getBytes	()[B
    //   102: invokevirtual 334	java/io/OutputStream:write	([B)V
    //   105: iconst_0
    //   106: ifeq +7 -> 113
    //   109: aconst_null
    //   110: invokevirtual 353	java/io/BufferedInputStream:close	()V
    //   113: return
    //   114: astore 9
    //   116: new 284	WeiboException
    //   119: dup
    //   120: aload 9
    //   122: invokespecial 308	WeiboException:<init>	(Ljava/lang/Exception;)V
    //   125: athrow
    //   126: astore 7
    //   128: iconst_0
    //   129: ifeq +7 -> 136
    //   132: aconst_null
    //   133: invokevirtual 353	java/io/BufferedInputStream:close	()V
    //   136: aload 7
    //   138: athrow
    //   139: astore 8
    //   141: new 284	WeiboException
    //   144: dup
    //   145: aload 8
    //   147: invokespecial 308	WeiboException:<init>	(Ljava/lang/Exception;)V
    //   150: athrow
    //   151: astore 11
    //   153: new 284	WeiboException
    //   156: dup
    //   157: aload 11
    //   159: invokespecial 308	WeiboException:<init>	(Ljava/lang/Exception;)V
    //   162: athrow
    //
    // Exception table:
    //   from	to	target	type
    //   69	105	114	java/io/IOException
    //   69	105	126	finally
    //   116	126	126	finally
    //   132	136	139	java/io/IOException
    //   109	113	151	java/io/IOException
  }

  public static boolean isBundleEmpty(WeiboParameters paramWeiboParameters)
  {
    int i;
    if ((paramWeiboParameters == null) || (paramWeiboParameters.size() == 0))
      i = 1;
    while (true)
    {
      return i;
      i = 0;
    }
  }

  public static String openUrl(Context paramContext, String paramString1, String paramString2, WeiboParameters paramWeiboParameters, Token paramToken)
    throws WeiboException
  {
    String str3;
    String str1 = "";
    int i = 0;
    if (i >= paramWeiboParameters.size())
    {
      if (!(TextUtils.isEmpty(str1)))
        break label78;
      str3 = openUrl(paramContext, paramString1, paramString2, paramWeiboParameters, null, paramToken);
    }
    while (true)
    {
      while (true)
      {
        return str3;
        String str2 = paramWeiboParameters.getKey(i);
        if (str2.equals("pic"))
        {
          str1 = paramWeiboParameters.getValue(str2);
          paramWeiboParameters.remove(str2);
        }
        ++i;
      }
      label78: str3 = openUrl(paramContext, paramString1, paramString2, paramWeiboParameters, str1, paramToken);
    }
  }

  // ERROR //
  public static String openUrl(Context paramContext, String paramString1, String paramString2, WeiboParameters paramWeiboParameters, String paramString3, Token paramToken)
    throws WeiboException
  {
    // Byte code:
    //   0: aload_0
    //   1: invokestatic 373	com/weibo/net/Utility:getHttpClient	(Landroid/content/Context;)Lorg/apache/http/client/HttpClient;
    //   4: astore 7
    //   6: aload_2
    //   7: ldc 17
    //   9: invokevirtual 368	java/lang/String:equals	(Ljava/lang/Object;)Z
    //   12: ifeq +132 -> 144
    //   15: new 115	java/lang/StringBuilder
    //   18: dup
    //   19: aload_1
    //   20: invokestatic 190	java/lang/String:valueOf	(Ljava/lang/Object;)Ljava/lang/String;
    //   23: invokespecial 174	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   26: ldc_w 375
    //   29: invokevirtual 132	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   32: aload_3
    //   33: invokestatic 377	com/weibo/net/Utility:encodeUrl	(Lcom/weibo/net/WeiboParameters;)Ljava/lang/String;
    //   36: invokevirtual 132	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   39: invokevirtual 124	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   42: astore_1
    //   43: new 379	org/apache/http/client/methods/HttpGet
    //   46: dup
    //   47: aload_1
    //   48: invokespecial 380	org/apache/http/client/methods/HttpGet:<init>	(Ljava/lang/String;)V
    //   51: astore 12
    //   53: aload_2
    //   54: aload 12
    //   56: aload_3
    //   57: aload_1
    //   58: aload 5
    //   60: invokestatic 384	com/weibo/net/Utility:setHeader	(Ljava/lang/String;Lorg/apache/http/client/methods/HttpUriRequest;Lcom/weibo/net/WeiboParameters;Ljava/lang/String;Lcom/weibo/net/Token;)V
    //   63: aload 7
    //   65: aload 12
    //   67: invokeinterface 388 2 0
    //   72: astore 13
    //   74: aload 13
    //   76: invokeinterface 394 1 0
    //   81: astore 14
    //   83: aload 14
    //   85: invokeinterface 399 1 0
    //   90: istore 15
    //   92: iload 15
    //   94: sipush 200
    //   97: if_icmpeq +201 -> 298
    //   100: aload 13
    //   102: invokestatic 403	com/weibo/net/Utility:read	(Lorg/apache/http/HttpResponse;)Ljava/lang/String;
    //   105: pop
    //   106: new 284	WeiboException
    //   109: dup
    //   110: aload 14
    //   112: invokevirtual 404	java/lang/Object:toString	()Ljava/lang/String;
    //   115: iconst_0
    //   116: anewarray 4	java/lang/Object
    //   119: invokestatic 408	java/lang/String:format	(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    //   122: iload 15
    //   124: invokespecial 409	WeiboException:<init>	(Ljava/lang/String;I)V
    //   127: athrow
    //   128: astore 18
    //   130: aload 18
    //   132: astore 6
    //   134: new 284	WeiboException
    //   137: dup
    //   138: aload 6
    //   140: invokespecial 308	WeiboException:<init>	(Ljava/lang/Exception;)V
    //   143: athrow
    //   144: aload_2
    //   145: ldc 20
    //   147: invokevirtual 368	java/lang/String:equals	(Ljava/lang/Object;)Z
    //   150: ifeq +126 -> 276
    //   153: new 411	org/apache/http/client/methods/HttpPost
    //   156: dup
    //   157: aload_1
    //   158: invokespecial 412	org/apache/http/client/methods/HttpPost:<init>	(Ljava/lang/String;)V
    //   161: astore 8
    //   163: aconst_null
    //   164: checkcast 414	[B
    //   167: pop
    //   168: new 416	java/io/ByteArrayOutputStream
    //   171: dup
    //   172: ldc_w 417
    //   175: invokespecial 420	java/io/ByteArrayOutputStream:<init>	(I)V
    //   178: astore 10
    //   180: aload 4
    //   182: invokestatic 360	android/text/TextUtils:isEmpty	(Ljava/lang/CharSequence;)Z
    //   185: ifne +63 -> 248
    //   188: aload 10
    //   190: aload_3
    //   191: invokestatic 424	com/weibo/net/Utility:paramToUpload	(Ljava/io/OutputStream;Lcom/weibo/net/WeiboParameters;)V
    //   194: aload 8
    //   196: ldc_w 426
    //   199: ldc_w 428
    //   202: invokevirtual 430	org/apache/http/client/methods/HttpPost:setHeader	(Ljava/lang/String;Ljava/lang/String;)V
    //   205: aload 10
    //   207: aload 4
    //   209: invokestatic 436	android/graphics/BitmapFactory:decodeFile	(Ljava/lang/String;)Landroid/graphics/Bitmap;
    //   212: invokestatic 438	com/weibo/net/Utility:imageContentToUpload	(Ljava/io/OutputStream;Landroid/graphics/Bitmap;)V
    //   215: aload 10
    //   217: invokevirtual 441	java/io/ByteArrayOutputStream:toByteArray	()[B
    //   220: astore 11
    //   222: aload 10
    //   224: invokevirtual 442	java/io/ByteArrayOutputStream:close	()V
    //   227: aload 8
    //   229: new 444	org/apache/http/entity/ByteArrayEntity
    //   232: dup
    //   233: aload 11
    //   235: invokespecial 446	org/apache/http/entity/ByteArrayEntity:<init>	([B)V
    //   238: invokevirtual 450	org/apache/http/client/methods/HttpPost:setEntity	(Lorg/apache/http/HttpEntity;)V
    //   241: aload 8
    //   243: astore 12
    //   245: goto -192 -> 53
    //   248: aload 8
    //   250: ldc_w 426
    //   253: ldc_w 452
    //   256: invokevirtual 430	org/apache/http/client/methods/HttpPost:setHeader	(Ljava/lang/String;Ljava/lang/String;)V
    //   259: aload 10
    //   261: aload_3
    //   262: invokestatic 454	com/weibo/net/Utility:encodeParameters	(Lcom/weibo/net/WeiboParameters;)Ljava/lang/String;
    //   265: ldc 134
    //   267: invokevirtual 456	java/lang/String:getBytes	(Ljava/lang/String;)[B
    //   270: invokevirtual 457	java/io/ByteArrayOutputStream:write	([B)V
    //   273: goto -58 -> 215
    //   276: aload_2
    //   277: ldc 14
    //   279: invokevirtual 368	java/lang/String:equals	(Ljava/lang/Object;)Z
    //   282: ifeq +26 -> 308
    //   285: new 459	org/apache/http/client/methods/HttpDelete
    //   288: dup
    //   289: aload_1
    //   290: invokespecial 460	org/apache/http/client/methods/HttpDelete:<init>	(Ljava/lang/String;)V
    //   293: astore 12
    //   295: goto -242 -> 53
    //   298: aload 13
    //   300: invokestatic 403	com/weibo/net/Utility:read	(Lorg/apache/http/HttpResponse;)Ljava/lang/String;
    //   303: astore 16
    //   305: aload 16
    //   307: areturn
    //   308: aconst_null
    //   309: astore 12
    //   311: goto -258 -> 53
    //   314: astore 6
    //   316: goto -182 -> 134
    //
    // Exception table:
    //   from	to	target	type
    //   106	128	128	java/io/IOException
    //   0	106	314	java/io/IOException
    //   144	305	314	java/io/IOException
  }

  private static void paramToUpload(OutputStream paramOutputStream, WeiboParameters paramWeiboParameters)
    throws WeiboException
  {
    int i = 0;
    if (i >= paramWeiboParameters.size())
      return;
    String str = paramWeiboParameters.getKey(i);
    StringBuilder localStringBuilder = new StringBuilder(10);
    localStringBuilder.setLength(0);
    localStringBuilder.append("--7cd4a6d158c").append("\r\n");
    localStringBuilder.append("content-disposition: form-data; name=\"").append(str).append("\"\r\n\r\n");
    localStringBuilder.append(paramWeiboParameters.getValue(str)).append("\r\n");
    byte[] arrayOfByte = localStringBuilder.toString().getBytes();
    try
    {
      paramOutputStream.write(arrayOfByte);
      ++i;
    }
    catch (IOException localIOException)
    {
      throw new WeiboException(localIOException);
    }
  }

  public static Bundle parseUrl(String paramString)
  {
    Bundle localBundle1;
    String str = paramString.replace("fbconnect", "http");
    try
    {
      URL localURL = new URL(str);
      Bundle localBundle2 = decodeUrl(localURL.getQuery());
      localBundle2.putAll(decodeUrl(localURL.getRef()));
      localBundle1 = localBundle2;
      return localBundle1;
    }
    catch (MalformedURLException localMalformedURLException)
    {
      localBundle1 = new Bundle();
    }
  }

  private static String read(InputStream paramInputStream)
    throws IOException
  {
    StringBuilder localStringBuilder = new StringBuilder();
    BufferedReader localBufferedReader = new BufferedReader(new InputStreamReader(paramInputStream), 1000);
    String str = localBufferedReader.readLine();
    while (true)
    {
      if (str == null)
      {
        paramInputStream.close();
        return localStringBuilder.toString();
      }
      localStringBuilder.append(str);
      str = localBufferedReader.readLine();
    }
  }

  private static String read(HttpResponse paramHttpResponse)
    throws WeiboException
  {
    HttpEntity localHttpEntity = paramHttpResponse.getEntity();
    try
    {
      Object localObject = localHttpEntity.getContent();
      ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
      Header localHeader = paramHttpResponse.getFirstHeader("Content-Encoding");
      if ((localHeader != null) && (localHeader.getValue().toLowerCase().indexOf("gzip") > -1))
        localObject = new GZIPInputStream((InputStream)localObject);
      byte[] arrayOfByte = new byte[512];
      int i = ((InputStream)localObject).read(arrayOfByte);
      if (i == -1)
        return new String(localByteArrayOutputStream.toByteArray());
      localByteArrayOutputStream.write(arrayOfByte, 0, i);
    }
    catch (IllegalStateException localIllegalStateException)
    {
      throw new WeiboException(localIllegalStateException);
    }
    catch (IOException localIOException)
    {
      throw new WeiboException(localIOException);
    }
  }

  public static void setAuthorization(HttpHeaderFactory paramHttpHeaderFactory)
  {
    mAuth = paramHttpHeaderFactory;
  }

  public static void setHeader(String paramString1, HttpUriRequest paramHttpUriRequest, WeiboParameters paramWeiboParameters, String paramString2, Token paramToken)
    throws WeiboException
  {
    int i;
    if (!(isBundleEmpty(mRequestHeader)))
      i = 0;
    while (true)
    {
      if (i >= mRequestHeader.size())
      {
        if (!(isBundleEmpty(paramWeiboParameters)))
          paramHttpUriRequest.setHeader("Authorization", mAuth.getWeiboAuthHeader(paramString1, paramString2, paramWeiboParameters, Weibo.APP_KEY, Weibo.APP_SECRET, paramToken));
        paramHttpUriRequest.setHeader("User-Agent", System.getProperties().getProperty("http.agent") + " WeiboAndroidSDK");
        return;
      }
      String str = mRequestHeader.getKey(i);
      paramHttpUriRequest.setHeader(str, mRequestHeader.getValue(str));
      ++i;
    }
  }

  public static void setRequestHeader(WeiboParameters paramWeiboParameters)
  {
    mRequestHeader.addAll(paramWeiboParameters);
  }

  public static void setRequestHeader(String paramString1, String paramString2)
  {
    mRequestHeader.add(paramString1, paramString2);
  }

  public static void setTokenObject(Token paramToken)
  {
    mToken = paramToken;
  }

  public static void showAlert(Context paramContext, String paramString1, String paramString2)
  {
    AlertDialog.Builder localBuilder = new AlertDialog.Builder(paramContext);
    localBuilder.setTitle(paramString1);
    localBuilder.setMessage(paramString2);
    localBuilder.create().show();
  }
}